package cn.com.eado.crm.v.activity

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import cn.com.eado.crm.R
import cn.com.eado.crm.app.extenstion.getFragment
import cn.com.eado.crm.v.fragment.HomeFragment
import cn.com.eado.crm.v.fragment.LoginFragment

class MainActivity : AppCompatActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
    }


    //不同页面按返回键处理
    override fun onBackPressed() {
        //判断当前是哪个fragment
        val fragment1 = getFragment(LoginFragment::class.java)
        if (fragment1 != null){
            finish()
        }else{
            val fragment2 = getFragment(HomeFragment::class.java)
            if (fragment2 != null){
//                finish()
                moveTaskToBack(true)
            }else{
                super.onBackPressed()
            }
        }
    }
}
